﻿using MyCanFD;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace CarPCBATest.Procedure
{

    public class S12L_LedB : S12L_Led
    {
        protected override void SendControlLedCommand()
        {
            if (counter % 2 == 0)
            {
                canFd.SendMessage(0x276, "00 00 00 00 00 00 00 00", 0);
            }

            if (counter % 2 == 1)
            {
                byte stopLedLightness = Convert.ToByte(StopLedLightness);
                byte turnLeftLedLightness = Convert.ToByte(TurnLeftLedLightness);
                byte turnRightLedLightness = Convert.ToByte(TurnRightLedLightness);

                byte[] cmd0x27B = { stopLedLightness };
                cmd0x27B = cmd0x27B.Concat(Enumerable.Repeat(turnLeftLedLightness, 42)).Concat(Enumerable.Repeat(turnRightLedLightness, 21)).ToArray();

                byte[] cmd0x27C = Enumerable.Repeat(turnRightLedLightness, 21).Concat(Enumerable.Repeat((byte)0, 43)).ToArray();
                canFd.SendMessage(0x27B, cmd0x27B, 0);
                canFd.SendMessage(0x27C, cmd0x27C, 0);                                                                                                                                                                                                    //canFd.SendMessage(0x277, "20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ", 0);
            }
            counter++;
        }

    }
}